{include inc/top.html}
<script src="{__CURTPL_URL__}js/ga.js"></script>
<script src="{__DATA_URL__}dialog/lhgdialog.min.js?self=true&skin=discuz"></script>
<script>
    var i = 0;
    $(function(){

        $('.resize').bind('dblclick' , function(){
            if($(this).height() <= 50){
                $(this).css('height' , 120);
            }else{
                $(this).css('height' , 20);
            }
        });

        $('.item_a').bind('click' , function(){
            var index = parseInt($(this).attr('index'));
            $('.item').removeClass('active');
            $(this).parent().addClass('active');
            $(this).blur();
            $('.iview').hide();
            $('#iview_' + index).show();
            $('#ga-test').attr('ajaxurl' , '{url:'admin@gather-debug-id-%d-k-|false' , $id}' + (index-1));
            $('#ga-test').attr('title'   , $(this).text() + ' 测试');
            i = index;
        });

        $('#ga-save').bind('click' , function(){
            var param = {};
            $('#iview_' + i).find('textarea').each(function(){
                param[$(this).attr('name')] = $(this).val();
            });
            $.ajax({
                type     : "POST",
                url      : '{url:'admin@gather-up-id-%d' , $id}',
                data     : param,
                success: function(msg){
                    alert(msg);
                }
            });
        });

        $('.item_a :first').trigger('click');
    });
</script>
<div class="index-main">
    <h1 class="h-title">{$atitle}
        <span class="sub-nav">
            <a href="{url:'admin@gather-list' , $ctype}">返回列表</a>
        </span>
     </h1>
    <form action="{url:'admin@gather-add-id-%d-step-%d' ,$id , count($config) - 1}" id="form" method="post" class="form">
        <div class="leftbar">
            <ol>
            {foreach $config $k $v}
                <li class="item">{$k_index}. <a href="javascript:void(0);" index="{$k_index}" class="item_a">{$v['name']}</a></li>
            {/foreach}
            </ol>
            <div class="view">
            {foreach $config $k $v}
                <div class="iview" id="iview_{$k_index}">
                    {foreach $v['rule'] $sk $sv}
                    <div>{$v['name']} - {$sv['name']}</div>
                    <div>
                        <textarea name="gather[{$sv['key']}]">{:htmlspecialchars($ga[$sv['key']])}</textarea>
                    </div>
                    {/foreach}
                </div>
            {/foreach}
            <a href="javascript:void(0);" class="ga-btn" id="ga-save">保存</a>
            <a href="javascript:void(0);" class="dialog ga-btn" title="测试" ajaxurl="" id="ga-test">测试</a>
            <div class="clear"></div>
        </div>
    </form>
    <div class="clear"></div>
</div>
{include inc/bottom.html}